package test.h0820;

import java.util.Arrays;
import java.util.LinkedList;
import java.util.Scanner;
import java.util.StringJoiner;

/**
 * @author 不知名帅哥
 * @version 1.0
 * @description 转盘寿司
 * @date 2024/8/20 10:26
 */
public class Main3 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] sushis = Arrays.stream(sc.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
        getRes(sushis);
    }

    private static void getRes(int[] sushis) {
        LinkedList<int[]> stack = new LinkedList<>();
        int[] ans = Arrays.copyOf(sushis,sushis.length);
        for (int i = 0; i < sushis.length; i++) {
            while (!stack.isEmpty() && stack.peekLast()[0] > sushis[i]) {
                int[] temp = stack.removeLast();
                ans[temp[1]] += sushis[i];
            }
            stack.addLast(new int[]{sushis[i], i});
        }

        for (int i = 0; i < sushis.length; i++) {
            while (!stack.isEmpty() && stack.peekLast()[0] > sushis[i]) {
                int[] temp = stack.removeLast();
                ans[temp[1]] += sushis[i];
            }
        }
        StringJoiner joiner = new StringJoiner(" ");
        for (int an : ans) {
            joiner.add(an + "");
        }
        System.out.println(joiner);
    }
}
